package com.game;

import android.content.res.Resources;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;

import com.javenwong.android.engine.ImageManager; 
import com.util.T;

/**
 * 被打时调的会动的血
 * 
 * @author Administrator
 * 
 */
public class HitPoint {

	private int x, y;
	private int dir;

	private byte dy = -12, time;

	private String str;
	private Bitmap numImage;

	public HitPoint(int x, int y, int dir, int num) { 
		numImage = ImageManager.getBitmap("images/number.png");
		this.x = x;
		this.y = y;
		this.dir = dir;
		str = num + "";

		// this.x -= MainCanvas.font.stringWidth(str) >> 1;
	}

	public void draw(Canvas g, int cameraX, int cameraY) {
		T.drawNum(numImage, g, str, x - cameraX, y - cameraY);
		x += dir == 2 ? -3 : 3;
		y += dy;
		dy += 5;
		switch (time) {
		case 0:
			if (dy > 18) {
				dy = -9;
				time++;
			}
			break;
		case 1:
			if (dy > 12) {
				dy = -6;
				time++;
			}
			break;
		case 2:
			if (dy > 4) {
				dy = -2;
				time++;
			}
			break;
		case 3:
			time++;
			break;
		}
	}

	public boolean isEnd() {
		return time > 3;
	}
}
